//
//  StockGoodsRankContentTableViewCell.m
//  quxiangtao
//
//  Created by xbmios on 2018/7/26.
//  Copyright © 2018年 shanhaijin. All rights reserved.
//

#import "StockGoodsRankContentTableViewCell.h"


@interface StockGoodsRankContentTableViewCell ()

@property (strong, nonatomic) UIImageView *iconIV;
@property (strong, nonatomic) UILabel *userL;
@property (strong, nonatomic) UILabel *desL;
@property (strong, nonatomic) UILabel *timeL;

@property (strong, nonatomic) UIView *lineV;

@end

@implementation StockGoodsRankContentTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self.contentView addSubview:self.iconIV];
        [self.contentView addSubview:self.userL];
        [self.contentView addSubview:self.desL];
        [self.contentView addSubview:self.timeL];
        [self.contentView addSubview:self.mvpIV];
        [self.contentView addSubview:self.lineV];
        
    }
    
    return self;
}

- (void)setType:(NSInteger)type {
    
    _type = type;
    
    if (type == 0) {
        
        self.mvpIV.image = [UIImage imageNamed:@"MVPbg"];
   
    }else {
        
        self.mvpIV.image = [UIImage imageNamed:@"stockSuperBG"];
    }
    
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    __weak typeof(self) weakSelf = self;
    [self.iconIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.contentView.mas_left).with.offset(jisuan(20));
        make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
        make.width.mas_equalTo(jisuan(70));
        make.height.mas_equalTo(jisuan(70));
    }];
    [self.userL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.iconIV.mas_right).with.offset(jisuan(20));
        make.top.mas_equalTo(weakSelf.iconIV.mas_top);
    }];

    [self.desL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.iconIV.mas_right).with.offset(jisuan(20));
        make.bottom.mas_equalTo(weakSelf.iconIV.mas_bottom);
    }];
    [self.timeL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(weakSelf.contentView.mas_right).with.offset(-jisuan(20));
        make.bottom.mas_equalTo(weakSelf.iconIV.mas_bottom);
    }];
    [self.mvpIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(weakSelf.userL.mas_centerY);
        make.right.mas_equalTo(weakSelf.contentView.mas_right).with.offset(-jisuan(20));
        make.width.mas_equalTo(jisuan(66));
        make.height.mas_equalTo(jisuan(40));
    }];
    
    [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.contentView.mas_left).with.offset(jisuan(20));
        make.right.mas_equalTo(weakSelf.contentView.mas_right).with.offset(-jisuan(20));
        make.bottom.mas_equalTo(weakSelf.contentView.mas_bottom);
        make.height.mas_equalTo(jisuan(2));
    }];
    
}

#pragma mark -lazy

- (UIView *)lineV {
    
    if (!_lineV) {
        
        _lineV = [[UIView alloc] init];
        _lineV.backgroundColor = Colordddddd;
        
    }
    return _lineV;
}
- (UIImageView *)iconIV {
    
    if (!_iconIV) {
        
        _iconIV = [[UIImageView alloc] init];
        _iconIV.contentMode = UIViewContentModeScaleAspectFit;
        _iconIV.layer.cornerRadius = jisuan(35);
        _iconIV.layer.masksToBounds = YES;
    }
    
    return _iconIV;
}
- (UIImageView *)mvpIV {
    
    if (!_mvpIV) {
        
        _mvpIV = [[UIImageView alloc] init];
        _mvpIV.contentMode = UIViewContentModeScaleAspectFit;
    }
    
    return _mvpIV;
}
- (UILabel *)userL {
    
    if (!_userL) {
        
        _userL = [[UILabel alloc] init];
        _userL.text = @"139******01";
        _userL.textColor = Color999999;
        _userL.font = Font(20);
        _userL.textAlignment = NSTextAlignmentLeft;
        
    }
    return _userL;
}
- (UILabel *)desL {
    
    if (!_desL) {
        
        _desL = [[UILabel alloc] init];
//        _desL.text = @"139******01";
//        _desL.textColor = Color999999;
        _desL.font = Font(20);
        _desL.textAlignment = NSTextAlignmentLeft;
        
        NSString *str = @"进货3份";
        NSMutableAttributedString *attributeStr = [[NSMutableAttributedString alloc] initWithString:str];
        [attributeStr addAttribute:NSForegroundColorAttributeName value:Color999999 range:NSMakeRange(0, 2)];
        [attributeStr addAttribute:NSForegroundColorAttributeName value:Color999999 range:NSMakeRange(str.length - 1  , 1)];
        [attributeStr addAttribute:NSForegroundColorAttributeName value:Color1f89ff range:NSMakeRange(2, str.length - 3)];
        _desL.attributedText = attributeStr;
        
        
    }
    return _desL;
}
- (UILabel *)timeL {
    
    if (!_timeL) {
        
        _timeL = [[UILabel alloc] init];
        _timeL.text = @"2018/01/26";
        _timeL.textColor = Color999999;
        _timeL.font = Font(20);
        _timeL.textAlignment = NSTextAlignmentRight;
        
    }
    return _timeL;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
